<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>
        谷粒商城 - seventeenw的博客
      </title>
    <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  
  <meta name="theme-color" content="#000000" />
  
  <meta http-equiv="window-target" content="_top" />
  
  
  <meta name="description" content="1.安装linux虚拟机 VirtualBox： 地址：https://www.virtualbox.org/ 通过vagrant来安装linux" />
  <meta name="generator" content="Hugo 0.59.1 with theme pure" />
  <title>谷粒商城 - seventeenw的博客</title>
  

  <link rel="stylesheet" href="https://seventeenw.gitee.io/blogs/css/style.css">
  <link rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/9.15.10/styles/github.min.css">
  <meta property="og:title" content="谷粒商城" />
<meta property="og:description" content="1.安装linux虚拟机 VirtualBox： 地址：https://www.virtualbox.org/ 通过vagrant来安装linux" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://seventeenw.gitee.io/blogs/2020/04/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/" />
<meta property="article:published_time" content="2020-04-16T10:01:35+08:00" />
<meta property="article:modified_time" content="2020-04-16T10:01:35+08:00" />
<meta itemprop="name" content="谷粒商城">
<meta itemprop="description" content="1.安装linux虚拟机 VirtualBox： 地址：https://www.virtualbox.org/ 通过vagrant来安装linux">


<meta itemprop="datePublished" content="2020-04-16T10:01:35&#43;08:00" />
<meta itemprop="dateModified" content="2020-04-16T10:01:35&#43;08:00" />
<meta itemprop="wordCount" content="2185">



<meta itemprop="keywords" content="" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="谷粒商城"/>
<meta name="twitter:description" content="1.安装linux虚拟机 VirtualBox： 地址：https://www.virtualbox.org/ 通过vagrant来安装linux"/>

  <!--[if lte IE 9]>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
    <![endif]-->

  <!--[if lt IE 9]>
      <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->

</head>
  </head>
  <body class="main-center theme-black" itemscope itemtype="http://schema.org/WebPage"><header class="header" itemscope itemtype="http://schema.org/WPHeader">
    <div class="slimContent">
      <div class="navbar-header">
        <div class="profile-block text-center">
          <a id="avatar" href="https://github.com/wengshiquan" target="_blank">
            <img class="img-circle img-rotate" src="https://seventeenw.gitee.io/blogs/avatar.png" width="200" height="200">
          </a>
          <h2 id="name" class="hidden-xs hidden-sm">17Null</h2>
          <h3 id="title" class="hidden-xs hidden-sm hidden-md">Java Developer</h3>
          <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i>Fuzhou, China</small>
        </div><div class="search" id="search-form-wrap">
    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="搜索" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i
                        class="icon icon-search"></i></button>
            </span>
        </div>
        <div class="ins-search">
            <div class="ins-search-mask"></div>
            <div class="ins-search-container">
                <div class="ins-input-wrapper">
                    <input type="text" class="ins-search-input" placeholder="想要查找什么..."
                        x-webkit-speech />
                    <button type="button" class="close ins-close ins-selectable" data-dismiss="modal"
                        aria-label="Close"><span aria-hidden="true">×</span></button>
                </div>
                <div class="ins-section-wrapper">
                    <div class="ins-section-container"></div>
                </div>
            </div>
        </div>
    </form>
</div>
        <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
        <ul class="nav navbar-nav main-nav">
            <li class="menu-item menu-item-home">
                <a href="/blogs/">
                    <i class="icon icon-home-fill"></i>
                  <span class="menu-title">主页</span>
                </a>
            </li>
            <li class="menu-item menu-item-reprint">
                <a href="/blogs/reprint">
                    <i class="icon icon-star-fill"></i>
                  <span class="menu-title">转载</span>
                </a>
            </li>
            <li class="menu-item menu-item-about">
                <a href="/blogs/about">
                    <i class="icon icon-cup-fill"></i>
                  <span class="menu-title">关于</span>
                </a>
            </li>
        </ul>
      </nav>
    </div>
  </header>
  <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">公告</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content"><p>一直想做前端的java程序员~</p>
            </div>
        </div>
    </div>
</div>

      <div class="widget">
    <h3 class="widget-title"> 分类</h3>
    <div class="widget-body">
        <ul class="category-list">
        </ul>
    </div>
</div>
      <div class="widget">
    <h3 class="widget-title"> 标签</h3>
    <div class="widget-body">
        <ul class="tag-list">
            
        </ul>

    </div>
</div>
      
<div class="widget">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget-body">
        <ul class="recent-post-list list-unstyled no-thumbnail">
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/vue-element-template-%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E7%9A%84%E5%BC%80%E5%8F%91%E6%B5%81%E7%A8%8B/" class="title">vue-element-template 从零开始的开发流程</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-25 22:51:58 &#43;0800 CST" itemprop="datePublished">2020-06-25</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/vue-element-template-%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E7%9A%84%E5%BC%80%E5%8F%91%E6%97%A5%E5%BF%97/" class="title">vue-element-template 从零开始的开发日志</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-25 22:49:21 &#43;0800 CST" itemprop="datePublished">2020-06-25</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/idea-springboot%E5%9B%BE%E6%A0%87%E4%B8%8D%E6%AD%A3%E7%A1%AE/" class="title">IDEA Springboot图标不正确</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-25 15:06:28 &#43;0800 CST" itemprop="datePublished">2020-06-25</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/%E6%A0%B9%E6%8D%AE%E6%95%B0%E6%8D%AE%E5%BA%93%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%E5%AE%9E%E4%BD%93%E7%B1%BB%E7%AD%89%E6%96%87%E4%BB%B6/" class="title">根据数据库自动生成实体类等文件</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-10 11:07:41 &#43;0800 CST" itemprop="datePublished">2020-06-10</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/springboot-quartz%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E8%A7%A3%E5%86%B3%E6%97%A0%E6%B3%95%E6%B3%A8%E5%85%A5%E5%8F%8A%E6%8C%81%E4%B9%85%E5%8C%96%E7%9A%84%E9%97%AE%E9%A2%98/" class="title">springboot&#43;quartz定时任务（解决无法注入bean及持久化的问题）</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-05 00:09:03 &#43;0800 CST" itemprop="datePublished">2020-06-05</time>
                    </p>
                </div>
            </li>
        </ul>
    </div>
</div>
  </div>
</aside>

    
    
  <aside class="sidebar sidebar-toc collapse" id="collapseToc" itemscope itemtype="http://schema.org/WPSideBar">
    <div class="slimContent">
      <nav id="toc" class="article-toc">
        <h3 class="toc-title">文章目录</h3>
        <div class="toc-content always-active"><nav id="TableOfContents">
<ul>
<li>
<ul>
<li>
<ul>
<li><a href="#1-安装linux虚拟机">1.安装linux虚拟机</a>
<ul>
<li>
<ul>
<li><a href="#virtualbox">VirtualBox：</a></li>
<li><a href="#通过vagrant来安装linux">通过vagrant来安装linux：</a></li>
</ul></li>
</ul></li>
<li><a href="#2-创建项目">2.创建项目</a></li>
<li><a href="#前端">前端</a>
<ul>
<li><a href="#2-解构表达式">2.解构表达式</a></li>
<li><a href="#3-函数优化">3.函数优化</a></li>
<li><a href="#4-对象优化">4.对象优化</a></li>
<li><a href="#5-promise">5.Promise</a></li>
<li><a href="#6-模块化">6.模块化</a></li>
</ul></li>
<li><a href="#后端">后端</a></li>
<li><a href="#跨域">跨域</a></li>
</ul></li>
</ul></li>
</ul>
</nav>
        </div>
      </nav>
    </div>
  </aside>
<main class="main" role="main"><div class="content">
  <article id="-" class="article article-type-" itemscope
    itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      <h1 itemprop="name">
  <a
    class="article-title"
    href="/blogs/2020/04/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/"
    >谷粒商城</a
  >
</h1>

      <div class="article-meta">
        <span class="article-date">
  <i class="icon icon-calendar-check"></i>
<a href="https://seventeenw.gitee.io/blogs/2020/04/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/" class="article-date">
  <time datetime="2020-04-16 10:01:35 &#43;0800 CST" itemprop="datePublished">2020-04-16</time>
</a>
</span>

        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/blogs/2020/04/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/#comments"
            class="article-comment-link">评论</a></span>
		<span class="post-wordcount hidden-xs" itemprop="wordCount">字数统计:2185字</span>
		<span class="post-readcount hidden-xs" itemprop="timeRequired">阅读时长:5分 </span>
      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody">
      

<h3 id="1-安装linux虚拟机">1.安装linux虚拟机</h3>

<h5 id="virtualbox">VirtualBox：</h5>

<p>地址：<a href="https://www.virtualbox.org/">https://www.virtualbox.org/</a></p>

<h5 id="通过vagrant来安装linux">通过vagrant来安装linux：</h5>

<p>地址：<a href="https://www.vagrantup.com/">https://www.vagrantup.com/</a></p>

<h3 id="2-创建项目">2.创建项目</h3>

<p><img src="https://gitee.com/w17null/imgs/raw/master/谷粒商城/image-20200414164102056.png" alt="https://gitee.com/w17null/imgs/raw/master/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/image-20200414164102056.png" /></p>

<p><img src="https://gitee.com/w17null/imgs/raw/master/谷粒商城/image-20200414172028193.png" alt="https://gitee.com/w17null/imgs/raw/master/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/image-20200414172028193.png" /></p>

<p><img src="https://gitee.com/w17null/imgs/raw/master/谷粒商城/image-20200414172040625.png" alt="https://gitee.com/w17null/imgs/raw/master/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/image-20200414172040625.png" /></p>

<p>商品服务、仓储服务、订单服务、优惠劵服务、用户服务</p>

<p>共同：</p>

<p>1） web、openfeign</p>

<p>2）每一个服务，包名 com.atguigu.gulimall.xxx(product/order/ware/coupon/member)</p>

<p>3）模块名：gulimall-coupon</p>

<p>随意复制一份pom.xml到父工程</p>

<pre><code class="language-xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

    &lt;groupId&gt;com.atguigu.gulimall&lt;/groupId&gt;
    &lt;artifactId&gt;gulimall&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;gulimall&lt;/name&gt;
    &lt;description&gt;聚合服务&lt;/description&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;


    &lt;modules&gt;
        &lt;module&gt;gulimall-product&lt;/module&gt;
        &lt;module&gt;gulimall-order&lt;/module&gt;
        &lt;module&gt;gulimall-ware&lt;/module&gt;
        &lt;module&gt;gulimall-coupon&lt;/module&gt;
        &lt;module&gt;gulimall-member&lt;/module&gt;
    &lt;/modules&gt;

&lt;/project&gt;
</code></pre>

<p>忽略文件：</p>

<pre><code class="language-gitignore">**/mvnw
**/mvnw.cmd
**/mvn
**/target/
.idea
**/.gitignore
</code></pre>

<p>提交工程</p>

<p>人人开源：</p>

<p><a href="https://www.renren.io/community/project">https://www.renren.io/community/project</a></p>

<p>renren-fast    <a href="https://gitee.com/renrenio/renren-fast">https://gitee.com/renrenio/renren-fast</a></p>

<p>renren-fast-vue  <a href="https://gitee.com/renrenio/renren-fast-vue">https://gitee.com/renrenio/renren-fast-vue</a></p>

<p>在数据库创建一个新库</p>

<p>renren-fast /db/mysql.sql</p>

<p>导入前端工程</p>

<p>renren-fast-vue</p>

<p>终端：</p>

<p>安装：npm install</p>

<p>运行：npm run dev</p>

<blockquote>
<p>关于新谷粒P16的前端项目使用npm install报错的问题，首先确保安装了python3.0以上版本，并配置全局变量
其次大部分错误是报node-sass4.9.0安装失败。
执行以下步骤可以完美解决
首先把项目文件夹下的package.json里面的node-sass4.9.0改成4.9.2（不改可能也没关系，不过我改了，防止踩坑）
然后项目文件夹下打开cmd命令窗口（和Visual Studio Code的终端命令是一样的）
执行：
npm i node-sass &ndash;sass_binary_site=<a href="https://npm.taobao.org/mirrors/node-sass/">https://npm.taobao.org/mirrors/node-sass/</a>
执行成功看看有没有报错，如果没报错执行下面命令
npm install ，
没报错就是安装成功，然后使用npm run dev 就ok了
注：这么做得原理就是先单独从淘宝镜像吧nod-sass下载下来，然后再进行编译，因为这句命令好像是不成功的，（npm config set registry <a href="http://registry.npm.taobao.org/），默认从github下载，导致报错的">http://registry.npm.taobao.org/），默认从github下载，导致报错的</a>
如果之前安装失败的。先清理 缓存
清理缓存：npm rebuild node-sass
           npm uninstall node-sass</p>
</blockquote>

<p>下载代码生成器</p>

<p>gitee：<a href="https://gitee.com/renrenio/renren-generator">https://gitee.com/renrenio/renren-generator</a></p>

<p>修改application.yml</p>

<p><img src="https://gitee.com/w17null/imgs/raw/master/谷粒商城/image-20200415114047454.png" alt="https://gitee.com/w17null/imgs/raw/master/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/image-20200415114047454.png" /></p>

<p>修改generator.properties</p>

<p><img src="https://gitee.com/w17null/imgs/raw/master/谷粒商城/image-20200415114105686.png" alt="https://gitee.com/w17null/imgs/raw/master/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/image-20200415114105686.png" /></p>

<p><img src="https://gitee.com/w17null/imgs/raw/master/谷粒商城/image-20200415113934377.png" alt="https://gitee.com/w17null/imgs/raw/master/%E8%B0%B7%E7%B2%92%E5%95%86%E5%9F%8E/image-20200415113934377.png" /></p>

<p>生成后将main文件夹复制到 gulimall-product 下</p>

<p>创建 gulimall-common 工程，将每一个微服务公共的依赖，bean，工具类放在这里</p>

<p>POM添加：</p>

<p>MyBatis-Plus</p>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;com.baomidou&lt;/groupId&gt;
    &lt;artifactId&gt;mybatis-plus-boot-starter&lt;/artifactId&gt;
    &lt;version&gt;3.2.0&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>lombok</p>

<pre><code class="language-xml">&lt;dependency&gt;
            &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
            &lt;artifactId&gt;lombok&lt;/artifactId&gt;
            &lt;version&gt;1.18.8&lt;/version&gt;
        &lt;/dependency&gt;
</code></pre>

<p>httpcomponents</p>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
    &lt;artifactId&gt;httpcore&lt;/artifactId&gt;
    &lt;version&gt;4.4.12&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>commons-lang</p>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;commons-lang&lt;/groupId&gt;
    &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
    &lt;version&gt;2.6&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>将逆向工程 resources /template/Controller.java.vm的</p>

<pre><code class="language-java">@RequiresPermissions(&quot;${moduleName}:${pathName}:list&quot;)
</code></pre>

<p>注释掉</p>

<p>导入mysql驱动</p>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;mysql&lt;/groupId&gt;
    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
    &lt;version&gt;8.0.17&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>删除 XssFilter  XssHttpServletRequestWrapper</p>

<p>在gulimall-product 的application.yml配置数据源相关信息</p>

<pre><code class="language-yml">spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://localhost:3306/gulimall_pms
    driver-class-name: com.mysql.jdbc.Driver
</code></pre>

<p>配置MyBatis-Plus</p>

<p>​   1）使用@MapperScan</p>

<p>GulimallProductApplication</p>

<pre><code class="language-java">@MapperScan(&quot;com.atguigu.gulimall.product.dao&quot;)
</code></pre>

<p>​   2）告诉Mybatis-Plus，sql映射文件位置</p>

<pre><code class="language-yml">mybatis-plus:
  mapper-locations: classpath*:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto
</code></pre>

<p>在 common 的pom文件中</p>

<pre><code class="language-xml">&lt;dependencyManagement&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.alibaba.cloud&lt;/groupId&gt;
            &lt;artifactId&gt;spring-cloud-alibaba-dependencies&lt;/artifactId&gt;
            &lt;version&gt;2.2.0.RELEASE&lt;/version&gt;
            &lt;type&gt;pom&lt;/type&gt;
            &lt;scope&gt;import&lt;/scope&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
&lt;/dependencyManagement&gt;
</code></pre>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;com.alibaba.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-starter-alibaba-nacos-discovery&lt;/artifactId&gt;
&lt;/dependency&gt;
</code></pre>

<p>在应用的 /src/main/resources/application.yml配置文件中配置 Nacos Server 地址</p>

<pre><code class="language-yml">server:
  port: 8000
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.application.name:gulimall-product
</code></pre>

<p>使用 @EnableDiscoveryClient 注解开启服务注册与发现功能</p>

<pre><code class="language-java"> @SpringBootApplication
 @EnableDiscoveryClient
 public class ProviderApplication {
 }
</code></pre>

<p>创建gateway项目</p>

<h3 id="前端">前端</h3>

<p>var</p>

<ul>
<li><p>声明的变量往往会越域</p></li>

<li><p>可以声明多次</p></li>

<li><p>会变量提升 （在之前调用会空值）</p></li>
</ul>

<p>let</p>

<ul>
<li><p>声明的变量有严格局部作用域</p></li>

<li><p>只能声明一次</p></li>

<li><p>不会变量提升（在之前调用会报错）</p></li>
</ul>

<p>const</p>

<ul>
<li>声明常量（不可改变）</li>
</ul>

<h4 id="2-解构表达式">2.解构表达式</h4>

<ul>
<li><p>数组解构</p>

<pre><code class="language-js">let arr = [1,2,3];
//赋值
let [a,b,c] =arr;
console.log(a,b,c);
</code></pre></li>

<li><p>对象解构</p>

<pre><code class="language-js">const person ={
  name:&quot;jack&quot;,
  age:21,
  language:['java','js','css']
}
//赋值
const {name:abc,age,language} = person;//从person里解出name赋给abc
console.log(abc,age,language)
</code></pre></li>

<li><p>字符串扩展</p>

<pre><code class="language-js">let str = &quot;hello.vue&quot;;
console.log(str.startWith(&quot;hello&quot;));
console.log(str.endsWith(&quot;.vue&quot;));
console.log(str.includes(&quot;e&quot;));
console.log(str.includes(&quot;hello&quot;));
</code></pre></li>

<li><p>字符串模板</p></li>
</ul>

<p>符号：``</p>

<pre><code class="language-js">  let ss =`&lt;div&gt;
  	&lt;span&gt;hello world&lt;/span&gt;
  	&lt;/div&gt;
  `
</code></pre>

<ul>
<li><p>字符串插入变量和表达式。变量名写在${}中</p>

<pre><code class="language-js">function fun (){
  return &quot;这是一个函数&quot;
}
let info = `我是${abc},我想说：${fun()}`;
</code></pre></li>
</ul>

<h4 id="3-函数优化">3.函数优化</h4>

<ul>
<li>箭头函数</li>
</ul>

<p>过去：</p>

<pre><code class="language-js">  var print = function(a,b){
      c = a+b
      return a+b;
  }
</code></pre>

<p>可缩写：</p>

<pre><code class="language-js">  var print = (a,b) =&gt; {
      c = a+b
      return a+c;
  };
</code></pre>

<h4 id="4-对象优化">4.对象优化</h4>

<ul>
<li>api</li>
</ul>

<p>Object.assign</p>

<pre><code class="language-js">  const target = {a:1}
  const source1 = {a:2}
  const source2 = {a:3}
  //方法的第一个参数是目标对象，后面的参数都是源对象
  Object.assign(target,source1,source2)
  console.log(target)//{a:1,b:2,c:3}
</code></pre>

<ul>
<li>对象拓展运算符</li>
</ul>

<p>1）拷贝对象（深拷贝）</p>

<pre><code class="language-js">  let p1 = {name:&quot;Amy&quot;,age:15}
  let someone = {...p1}
</code></pre>

<p>2）合并对象</p>

<pre><code class="language-js">  let p2 = {name:&quot;Amy&quot;,age:15}
  let p3 = {name:&quot;aa&quot;,age:16}
  let someone = {...p2, ...p3}
</code></pre>

<h4 id="5-promise">5.Promise</h4>

<p>​   1）Promise可以封装异步操作</p>

<pre><code class="language-js">let p = new Promise((resolve,reject) =&gt; {
    //1.异步操作
    $.ajax({
        url:&quot;mock/user.json&quot;,
        success:function(data){
            console.log(&quot;查询用户成功&quot;,data)
            resolve(data);
        },
        error:function(err){
            reject(err);
        }
    });
});

p.then((obj)=&gt;{
    ...
})
</code></pre>

<h4 id="6-模块化">6.模块化</h4>

<p>1）导出</p>

<pre><code class="language-js">const util = {
    sum(a,b){
        return a+b;
    }
}

export{util}
//'export' 不仅可以导出对象，一切js变量都可以导出，比如：基本数据变量、函数、数组、对象
</code></pre>

<p>2）导入</p>

<pre><code class="language-js">import util from './hello.js'
</code></pre>

<h3 id="后端">后端</h3>

<p>三级分类（树形）：<a href="https://www.bilibili.com/video/BV1np4y1C7Yf?p=45">https://www.bilibili.com/video/BV1np4y1C7Yf?p=45</a></p>

<h3 id="跨域">跨域</h3>

<p>跨域：指的是浏览器不能执行其他网站的脚本。它是由浏览器的同源策略造成的，是浏览器对javascript施加的安全限制。</p>

<p>同源策略：是指协议，域名，端口都要相同，其中有一个不同都会产生跨域；</p>

<p><img src="https://upload-images.jianshu.io/upload_images/9487719-d9eb2035e204d817.png?imageMogr2/auto-orient/strip|imageView2/2/format/webp" alt="img" /></p>

<pre><code class="language-java">package com.atguigu.gulimall.gateway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;

@Configuration
public class GulimallCorsConfiguration {

    @Bean
    public CorsWebFilter corsWebFilter(){
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();

        CorsConfiguration corsConfiguration = new CorsConfiguration();

        //1、配置跨域
        corsConfiguration.addAllowedHeader(&quot;*&quot;);//请求头
        corsConfiguration.addAllowedMethod(&quot;*&quot;);//请求方式
        corsConfiguration.addAllowedOrigin(&quot;*&quot;);//请求来源
        corsConfiguration.setAllowCredentials(true);//是否允许携带cookie跨域

        source.registerCorsConfiguration(&quot;/**&quot;,corsConfiguration);
        return new CorsWebFilter(source);
    }
}

</code></pre>

<p>把   renren-fast 的 E:\study\gulimall\renren-fast\src\main\java\io\renren\config\CorsConfig 的 addCorsMappings方法注释掉，和我们自己配置的跨域重复了</p>

    </div>
  </article>
<section id="comments">
</section>

</div><nav class="bar bar-footer clearfix" data-stick-bottom>
    <div class="bar-inner">
        <ul class="pager pull-left">
            <li class="prev">
                <a href="https://seventeenw.gitee.io/blogs/2020/04/springcloud-alibaba/" title="SpringCloud Alibaba"><i
                        class="icon icon-angle-left"
                        aria-hidden="true"></i><span>&nbsp;&nbsp;上一篇</span></a>
            </li>
            <li class="next">
                <a href="https://seventeenw.gitee.io/blogs/2020/04/%E5%A4%9A%E8%8A%82%E7%82%B9linux%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%8E%AF%E5%A2%83/"
                    title="多节点Linux操作系统环境"><span>下一篇&nbsp;&nbsp;</span><i
                        class="icon icon-angle-right" aria-hidden="true"></i></a>
            </li>
            
            <li class="toggle-toc">
                <a class="toggle-btn collapsed" data-toggle="collapse" href="#collapseToc" aria-expanded="false"
                    title="文章目录" role="button">
                    <span>[&nbsp;</span><span>文章目录</span>
                    <i class="text-collapsed icon icon-anchor"></i>
                    <i class="text-in icon icon-close"></i>
                    <span>]</span>
                </a>
            </li>
        </ul>
        <div class="bar-right">
            <div class="share-component" data-sites="weibo,qq,wechat,facebook,twitter"
                data-mobile-sites="weibo,qq,qzone"></div>
        </div>
    </div>
</nav>
</main><footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
<ul class="social-links">
    <li><a href="https://github.com/wengshiquan" target="_blank" title="github" data-toggle=tooltip data-placement=top >
            <i class="icon icon-github"></i></a></li>
    <li><a href="https://seventeenw.gitee.io/index.xml" target="_blank" title="rss" data-toggle=tooltip data-placement=top >
            <i class="icon icon-rss"></i></a></li>
    <li><a href="https://gitee.com/seventeenw" target="_blank" title="tags" data-toggle=tooltip data-placement=top >
            <i class="icon icon-tags"></i></a></li>
</ul>
  <div class="copyright">
    &copy;2017  -
    2020
    <div class="publishby">
        Theme by <a href="https://github.com/xiaoheiAh" target="_blank"> xiaoheiAh </a>base on<a href="https://github.com/xiaoheiAh/hugo-theme-pure" target="_blank"> pure</a>.
    </div>
  </div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
   window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/highlight.min.js"></script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/languages/rust.min.js"></script>
<script type="text/javascript"
   src="https://cdn.staticfile.org/highlight.js/9.15.10/languages/dockerfile.min.js"></script>
<script>
hljs.configure({
  tabReplace: '    ', 
  classPrefix: ''     
                      
})
hljs.initHighlightingOnLoad();
</script>
<script type="text/javascript" src="https://seventeenw.gitee.io/blogs/js/application.js"></script>
<script type="text/javascript" src="https://seventeenw.gitee.io/blogs/js/plugin.js"></script>
<script>
      (function (window) {
          var INSIGHT_CONFIG = {
              TRANSLATION: {
                  POSTS: '文章',
                  PAGES: '页面',
                  CATEGORIES: '分类',
                  TAGS: '标签',
                  UNTITLED: '(未命名)',
              },
              ROOT_URL: 'https:\/\/seventeenw.gitee.io\/blogs',
              CONTENT_URL: 'https:\/\/seventeenw.gitee.io\/blogs\/searchindex.json ',
          };
          window.INSIGHT_CONFIG = INSIGHT_CONFIG;
      })(window);
      </script>
<script type="text/javascript" src="https://seventeenw.gitee.io/blogs/js/insight.js"></script>

  </body>
</html>
